#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //点击打开文件，调用openFIle打开文件
    connect(ui->action,SIGNAL(triggered(bool)),ui->iView,SLOT(openFile()));
    //点击旋转按钮，调用turnImage进行图片旋转
    connect(ui->tImage,SIGNAL(valueChanged(int)),ui->iView,SLOT(turnImage(int)));
    //点击缩放按钮，调用scaleImage进行图片缩放
    connect(ui->sImage,SIGNAL(valueChanged(int)),ui->iView,SLOT(scaleImage(int)));
    //点击pushButton按钮，调用moveAnimation进行图片平移
    connect(ui->pushButton,SIGNAL(clicked(bool)),ui->iView,SLOT(moveAnimation()));
    //点击pushButton_2按钮，调用drawRect改变type值，然后绘制矩形
    connect(ui->pushButton_2,SIGNAL(clicked(bool)),ui->iView,SLOT(drawRect()));
     //点击pushButton_3按钮，调用drawEllipse改变type值，然后绘圆形
    connect(ui->pushButton_3,SIGNAL(clicked(bool)),ui->iView,SLOT(drawEllipse()));
    //iView发出信号，获取当前鼠标的RGB值，在状态栏进行展示
    connect(ui->iView,&ImageView::colorHovered,[&](const QColor color){
        QString test = "R: "+QString::number(color.red())+" G:"+QString::number(color.green())+" B:"+QString::number(color.blue());
        QStatusBar* statusBar = this->statusBar();
        statusBar->showMessage(test, 2000);
    });
}

MainWindow::~MainWindow()
{
    delete ui;
}
